<?php

/**
 * 社区设置
 * @author  Mr.L <349865361@qq.com>
 */

namespace app\topics\admin;


class ConfigAdmin extends \app\system\admin\SystemAdmin {

    /**
     * 模块信息
     */
    protected function _infoModule(){
        return array(
            'info' => array(
                'name' => '社区设置',
                'description' => '设置社区配置信息',
            ),
        );
    }

    /**
     * 基本设置
     */
    public function index() {
        if(!isPost()) {
            $info = target('TopicsConfig')->getConfig();
            $userList = [];
            if($info['manage_user']) {
                $userList = target('topics/TopicsUser')->loadList(['_sql' => 'user_id in('.$info['manage_user'].')']);
            }
            $this->assign('userList', $userList);
            $this->assign('info', $info);
            $this->systemDisplay();
        }else{
            $_POST['manage_user'] = implode(',', $_POST['manage_user']);
            if(target('TopicsConfig')->saveInfo()){
                $this->success('配置成功！');
            }else{
                $this->error('配置失败');
            }
        }
    }
}